<template>
  <div>
    <div>
      <el-button type="primary" size="small" @click="dialogFormVisible = true" icon="el-icon-edit">新建角色</el-button>
      <el-table :data="tableData">
        <el-table-column prop="number" label="角色账号" width="280" align="center">
        </el-table-column>
        <el-table-column prop="name" label="角色名称" width="180" align="center">
        </el-table-column>
        <el-table-column prop="jurisdiction" label="角色权限" width="280" align="center">
        </el-table-column>
        <el-table-column prop="state" label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleEdit(scope.row)" icon="el-icon-edit" >编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left:10px" @confirm="handleDel">
              <el-button slot="reference" type="danger" size="mini" icon="el-icon-delete" >删除</el-button>        
            </el-popconfirm>  
          </template>
            
        </el-table-column>
      </el-table>
    </div>
    <div>
      <el-dialog title="角色信息" :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item label="角色账号" :label-width="formLabelWidth">
            <el-input v-model="form.number" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="角色名称" :label-width="formLabelWidth">
            <el-input v-model="form.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="角色权限" :label-width="formLabelWidth">
            <el-input v-model="form.jurisdiction" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>

export default {
  name: "Role",
  components: {
    // JGIndex: ()=> import('../JGList/JGIndex.vue'),
  },

  data() {
    const items = {
      number: '146780089636531',
      name: '管理员',
      jurisdiction: '所有权限',
    };
    return {
      tableData: Array(20).fill(items),

      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        number: '',
        name: '',
        jurisdiction: '',
      },
      formLabelWidth: '120px'
    };
  },
  mounted() {
    
  },

  methods: {

    // 编辑
    handleEdit(row){
      this.dialogFormVisible = true
      console.log(row)
      this.form = {
        ...row
      }
    },
    // 删除
    handleDel(){
      this.$message({
        message: '删除成功',
        type: 'success'
      });
    }
    
  },
};
</script>

<style lang="less" scoped>

</style>
